<?php

namespace app\admin\model;

use think\Model;

class RegionCountry extends BaseModel
{

    /**
     * @describe 获取下拉框格式数据
     * @author: Bobo
     * @date: 2024-08-23 10:06:27
     * @param [type] @required
     * @return Renderable
     */
    public function getSelectOption(array $where, $fields = 'id, name')
    {
        $data = $this
            ->field($fields)
            ->where($where)
            ->select()
            ->toArray();

        $selectOption = [];
        foreach ($data as $option) {
            $selectOption[] = [
                'value' => intval($option['id']),
                'label' => $option['name'] ?? '',
                'country_code' => $option['country_code'] ?? '',
            ];
        }
        return $selectOption;
    }
}
